<div class="container">

	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-body">
					<form class="form-inline m-b-5" role="form">
						<div class="form-group m-b-5">
							<input type="text" class="form-control" placeholder="计划单号" id="id_search_planNo">
						</div>
					
						<div class="btn-group">
							<button type="button" class="btn btn-default waves-effect" onclick="search();">搜索</button>
							<button type="button" class="btn btn-default waves-effect" onclick="clearing();">清空</button>
						</div>
						<div class="btn-group pull-right">
							<a th:each="button : ${listButton}" type="button" class="btn btn-default waves-effect" th:onclick="'javascript:' + ${button.buttonfun} + ''" th:text="${button.buttonName}"></a>
						</div>
					</form>
					<div class="form-group">
						<table id="id_list_table_repay_plan"></table>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- End Row -->
	
	<div data-th-include="inter/repayPlan_repayPlanRunningList"></div>
	
	<!--
	<div data-th-include="inter/adminAdd"></div>
	-->
	<div data-th-include="inter/edit/repayPlanEdit"></div>
</div>
<!-- container -->
<script>
	$(function () {
	});

	var param = {
		orderby : 'id',
		sorttype : 'desc'
	};
	var columns = [
		{
			checkbox: true,
			align: 'center',
			valign: 'middle',
		},
		{
			field: 'SerialNumber',
			title: '序号',
			sortable: true,
			align: "center",
			width: 40,
			formatter: function (value, row, index) {
				return index + 1;
			}
		},
		{
			title: '单号',
			field: 'planNo',
			align: 'center',
			valign: 'middle',
		},
		{
			title: '还款总金额',
			field: 'totalAmount',
			align: 'center',
			valign: 'middle',
		},
		{
			title: '执行状态',
			field: 'state',
			align: 'center',
			valign: 'middle',
            formatter: function (value, row, index) {
                var returnStr;
                if (value == 100) {
                	returnStr = '代付款启动';
                } else if (value == 200) {
                	returnStr = '运行中';
                } else if (value == 300) {
                	returnStr = '已完成';
                } else if (value == 400) {
                	returnStr = '已失败';
                } else if (value == 500) {
                	returnStr = '已取消';
                }
                return returnStr;
            }
		},
		{
			title: '退款状态',
			field: 'refundState',
			align: 'center',
			valign: 'middle',
            formatter: function (value, row, index) {
                var returnStr;
                if (value == 0) {
                	returnStr = '待退款';
                } else if (value == 100) {
                	returnStr = '退款中';
                } else if (value == 200) {
                	returnStr = '已退款';
                } else if (value == 300) {
                	returnStr = '退款失败';
                }
                return returnStr;
            }
		},
		{
			title: '已还款金额',
			field: 'repayedAmount',
			align: 'center',
			valign: 'middle',
		},
		{
			title: '已消费金额',
			field: 'payedAmount',
			align: 'center',
			valign: 'middle',
		},
		{
			title: '通道',
			field: 'channelId',
			align: 'center',
			valign: 'middle',
            formatter: function (value, row, index) {
                var returnStr;
                if (value == 1) {
                	returnStr = '桔子还款';
                } else if (value == 2) {
                	returnStr = '快捷A（线上大额商户）';
                } else if (value == 3) {
                	returnStr = '开开支付';
                } else if (value == 4) {
                	returnStr = '快捷B（线下落地商户）';
                } else if (value == 5) {
                	returnStr = '通联';
                } else if (value == 6) {
                	returnStr = '枇杷还款';
                } else if (value == 7) {
                	returnStr = '芭乐还款';
                } else if (value == 8) {
                	returnStr = '迅力联还款';
                } else if (value == 9) {
                	returnStr = '新生还款';
                }
                return returnStr;
            }
		},
		{
			title: '备注',
			field: 'remark',
			align: 'center',
			valign: 'middle',
		},
		{
			title: '创建时间',
			field: 'createTime',
			align: 'center',
			valign: 'middle',
		}
	];
	var table = $BO.initTable("id_list_table_repay_plan", "/api/inter/repayPlan/search", param, columns, 5, $(window).height() / 2 - 200);

	//搜索
	function search() {
		param.planNo = $("#id_search_planNo").val();
		table.bootstrapTable("refreshOptions", {pageNumber: 1});
	}
	
	function clearing() {
		$("#id_search_planNo").val('');
		table.bootstrapTable("refreshOptions", {pageNumber: 1});
	}
	
	$('#id_list_table_repay_plan').on('click-row.bs.table', function (event, row, element, field) {
		param_repay_plan_ruuning.planId = row.id;
		table_repay_plan_ruuning.bootstrapTable("refreshOptions", {pageNumber: 1});
	})
</script>

<div th:if="${menu.menuDiy} ne ''">
	<div data-th-include="${menu.menuDiy}"></div>
</div>